package org.springblade.modules.mes.base.entity;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import org.springblade.core.tool.node.INode;
import org.springblade.core.tool.node.TreeNode;

import java.util.ArrayList;
import java.util.List;

@Data
public class DictTreeNode implements INode<DictTreeNode> {
    private String dictKey;
    private String dictValue;
    /**
     * 主键ID
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    /**
     * 父节点ID
     */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long parentId;

    /**
     * 子孙节点
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<DictTreeNode> children;
    @Override
    public List<DictTreeNode> getChildren() {
        if (this.children == null) {
            this.children = new ArrayList<>();
        }
        return this.children;
    }
    /**
     * 上级字典
     */
    private String parentName;
    private String title;
    @JsonSerialize(
            using = ToStringSerializer.class
    )
    private Long key;
    @JsonSerialize(
            using = ToStringSerializer.class
    )
    private Long value;
}
